<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>计算图书费用小程序</title>
		<script src="vue.js"></script>
	</head>

	<body>
		<div id="app">
			<p>欢迎使用计算图书费用小程序</p>
			<p>单价: {{price}}</p>
			<p>数量: {{num}}</p>
			<p>总价: {{toPrice}}</p>

			<button @click="num==0 ? 0:num--">减少数量</button>
			<button @click="num++">增加数量</button>
		</div>
	</body>
	<script>
		var vm = new Vue({
			el: "#app",
			data: {
				price: 35,
				num: 0
			},
			computed: {
				toPrice: function() {
					return(this.price * this.num - this.num*2)
				}
			},
			methods: {

			}
		})
	</script>

</html>